VideoOverlay : Video overlay

更新时间:
2024-05-15
下载文档

VideoOverlay : Video overlay

The videooverlay module provides video overlay function.

videooverlay is a sub object of MediaDecoder.

Support

The following shows videooverlay module APIs available for each permissions.

 User ModePrivilege Mode
videooverlay.clear
videooverlay.text
videooverlay.point
videooverlay.line
videooverlay.rect
videooverlay.circle
videooverlay.draw
videooverlay.font

VideoOverlay Object

videooverlay.clear()

  • Returns: {Boolean} Return true if success, otherwise false.

Clear all overlays.

videooverlay.text(x, y, text, color[, bcolor])

  • x {Integer} x position.
  • y {Integer} y position.
  • text {String} Text which need draw.
  • color {Integer} Text color.
  • bcolor {Integer} Background color.
  • Returns: {Boolean} Return true if success, otherwise false.

Draw a text on overlay.

videooverlay.point(x, y, color)

  • x {Integer} x position.
  • y {Integer} y position.
  • color {Integer} Point color.
  • Returns: {Boolean} Return true if success, otherwise false.

Draw a point on overlay.

videooverlay.line(x0, y0, x1, y1, color[, width])

  • x0 {Integer} x0 position.
  • y0 {Integer} y0 position.
  • x1 {Integer} x1 position.
  • y1 {Integer} y1 position.
  • color {Integer} Line color.
  • width {Integer} Line width.
  • Returns: {Boolean} Return true if success, otherwise false.

Draw a line on overlay.

videooverlay.rect(x0, y0, x1, y1, color[, width[, r[, fill]]])

  • x0 {Integer} x position of upper left corner.
  • y0 {Integer} y position of upper left corner.
  • x1 {Integer} x position of lower right corner.
  • y1 {Integer} y position of lower right corner.
  • color {Integer} Line color.
  • width {Integer} Line width.
  • r {Integer} The radius of fillet.
  • fill {Boolean} Does fill rectangle?
  • Returns: {Boolean} Return true if success, otherwise false.

Draw a rectangle on overlay.

videooverlay.circle(x, y, r, color[, width[, fill]])

  • x {Integer} x position of center.
  • y {Integer} y position of center.
  • r Integer Line color.
  • color {Integer} Line color.
  • width {Integer} Line width.
  • fill {Boolean} Does fill circle?
  • Returns: {Boolean} Return true if success, otherwise false.

Draw a circle on overlay.

videooverlay.font(font)

  • font {Integer} Font size.
  • Returns: {Boolean} Return true if success, otherwise false.

font is a integer, can be:

ValueDescription
F4X64X6 font.
F5X85X8 font.
F5X125X12 font.
F6X86X8 font.
F6X106X10 font.
F7X127X12 font.
F8X88X8 font.
F8X128X12 font.
F8X148X14 font.
F10X1610X16 font.
F12X1612X16 font.
F12X2012X20 font.
F16X2616X26 font.
F22X3622X36 font.
F24X4024X40 font.
F32X5332X53 font.

videooverlay.draw(buf)

  • buf {Buffer} Buffer which need to be draw.
  • Returns: {Boolean} Return true if success, otherwise false.

Draw all overlays to specified buffer.

Example

This example show how to draw something on the video overlay.

#!/bin/javascript

var MediaDecoder = require('mediadecoder');
var iosched = require('iosched');

var netcam = new MediaDecoder().open('rtsp://admin:admin@10.4.0.12');

netcam.destVideoFormat({width: 640, height: 360, fps: 1, pixelFormat: MediaDecoder.PIX_FMT_RGB24, disable: false});
netcam.destAudioFormat({disable: true});
netcam.previewFormat({enable: true, fb: 0, fps: 25});

var quited = false;

var ol = netcam.overlay();

ol.font(ol.F8X12);
ol.text(40, 20, 'EdgerOS', MediaDecoder.C_WHITE);
ol.point(40, 40, MediaDecoder.C_RED);
ol.line(40, 50, 80, 50, MediaDecoder.C_RED, 4);
ol.rect(40, 60, 80, 100, MediaDecoder.C_RED, 8, 2, true);
ol.circle(70, 140, 30, MediaDecoder.C_RED, 2);

netcam.on('video', (video) => {
});

netcam.on('eof', () => {
  quited = true;
});

netcam.start();

while (!quited) {
  iosched.poll(); // Event poll.
}

netcam.close();
文档内容是否对您有所帮助?
有帮助
没帮助